﻿using HongYeSystemWebApi.Templet.Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using static HongYeSystemWebApi.Templet.Entity.ApiResult.ApiResult;
using System.Threading.Tasks;
using HongYeSystemWebApi.Templet.Entity.ApiResult;
using HongYeSystemWebApi.Templet.IService;
using HongYeSystemWebApi.Templet.Entity.Request.SysProject;
using HongYeSystemWebApi.Templet.Entity.Request;
using HongYeSystemWebApi.Templet.Entity.Response;
using System.Collections.Generic;
using HongYeSystemWebApi.Templet.Entity.Entities;
using HongYeSystemWebApi.Templet.Entity.Response.Project;
using HongYeSystemWebApi.Templet.Entity.Request.SysExpenditure;

namespace HongYeSystemWebApi.Templet.Controllers
{
     
    public class ProjectController : BaseController
    {
        private readonly IProjectService _projectService;

        public ProjectController(IProjectService projectService)
        {
            _projectService = projectService;
        }
        /// <summary>
        /// 新增字段组
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("insert")]
        public async Task<ApiResult> InsertAsync([FromBody] SysProjectInsertRequest request)
        {
            await _projectService.InsertAsync(request);
            return ApiResult.True();
        }


        /// <summary>
        /// 更新字段组
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("update")]
        public async Task<ApiResult> UpdateAsync([FromBody] SysProjectUpdataRequest request)
        {
            await _projectService.UpdateAsync(request);
            return   ApiResult.True();
        }

        /// <summary>
        /// 删除字段组
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("delete")]
        public async Task<ApiResult> DeleteAsync([FromBody] MultiIdRequest request)
        {
            await _projectService.DeleteAsync(request);
            return ApiResult.True();
        }

        /// <summary>
        /// 查询字段组
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("query")]
        public async Task<ApiResult<PageModel<SysProjectDataPageResponse>>> GetListAsync([FromBody] SysProjectSelectRequest request)
        {
            var result = await _projectService.GetListAsync(request);
            return ApiResult.True(result);
        }



        /// <summary>
        /// 导出指定的文件数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("ExportByGetList")]
        public async Task<ApiResult> ExportByGetListAsync([FromBody] SysProjectSelectRequest request)
        {
            var result = await _projectService.ExportByGetListAsync(request);
            return ApiResult.True(result);
        }

        /// <summary>
        /// 导出所有文件数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost("ExportAll")]
        public async Task<ApiResult> ExportAll()
        {
            var result = await _projectService.ExportAll();
            return ApiResult.True(result);
        }
    }
}
